home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
001
/
pibt40s2.arc
/
OPENFORA.MOD
< prev
next >
Wrap
Text File
|
1987-03-31
|
3KB
|
68 lines
(*----------------------------------------------------------------------*)
(* Open_For_Append --- Open text file for appending to end *)
(*----------------------------------------------------------------------*)
FUNCTION Open_For_Append( VAR F : Text_File;
F_Name : AnyStr ;
VAR Error : INTEGER ) : BOOLEAN;
(*----------------------------------------------------------------------*)
(* *)
(* Function: Open_For_Append *)
(* *)
(* Purpose: Opens text file for append *)
(* *)
(* Calling Sequence: *)
(* *)
(* Open_OK := Open_For_Append( VAR F : Text_File; *)
(* F_Name : AnyStr ; *)
(* VAR Error : INTEGER ) : BOOLEAN; *)
(* *)
(* F --- Text file to be opened *)
(* F_Name --- File name of text file *)
(* Error --- I/O error encountered here *)
(* *)
(* Remarks: *)
(* *)
(* This routine exists to circumvent a bug in Turbo Pascal in *)
(* which an attempt to append text to an existing but empty *)
(* file causes death. *)
(* *)
(*----------------------------------------------------------------------*)
VAR
Open_Ok : BOOLEAN;
F_Byte : FILE OF BYTE;
BEGIN (* Open_For_Append *)
(*$I-*)
(* See if file exists or is empty. *)
(* File of byte req'd for filesize. *)
ASSIGN( F_Byte , F_Name );
RESET( F_Byte );
Error := Int24Result;
Open_OK := ( Error = 0 );
(* If file exists, but is empty, *)
(* use REWRITE to avoid error. *)
IF Open_OK THEN
IF ( LongFileSize( F_Byte ) = 0.0 ) THEN
Open_OK := FALSE;
CLOSE( F_Byte );
(* Now open file as text file. *)
ASSIGN( F , F_Name );
IF Open_OK THEN
APPEND( F )
ELSE
REWRITE( F );
Error := Int24Result;
Open_For_Append := ( Error = 0 );
(*$I+*)
END (* Open_For_Append *);